package com.deyuanyun.pic.ae.controller.vo;

import com.deyuanyun.pic.ae.domain.DifficultyRepair;
import com.deyuanyun.pic.common.util.NumberUtil;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.pipe.util.PipeMgrUtil;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;

/**
 * E_6维修接近信息统计表
 */
public class DifficultyRepairVO extends AEBaseVO<DifficultyRepair> {

    // 管道编号
    private String pipeLineName;
    // 编号
    private String customNumber;
    //(填写)平行起点_附近测试桩pic_pipe_identification.ID_
    private String beginNagmInput;
    // (填写)平行起点_附近测试桩距离（相对值）
    private BigDecimal beginNagmMileageInput;
    // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
    private String endNagmInput;
    // (填写)平行段终点_附近测试桩距离（相对值）
    private BigDecimal endNagmMileageInput;
    // 位置描述
    private String locationDescription;
    // 难以接近原因AE_DIFFICULTY_REPAIR_TYPE（沼泽、湖泊、水塘、山地、河流、建构筑物、其它）
    private String reason;
    // 数据状态
    private String dataStated;
    private String gisid;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public String getCustomNumber() {
        return customNumber;
    }

    public String getBeginNagmInput() {
        return beginNagmInput;
    }

    public BigDecimal getBeginNagmMileageInput() {
        return beginNagmMileageInput;
    }

    public String getEndNagmInput() {
        return endNagmInput;
    }

    public BigDecimal getEndNagmMileageInput() {
        return endNagmMileageInput;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public String getReason() {
        return reason;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public void setCustomNumber(String customNumber) {
        this.customNumber = customNumber;
    }

    public void setBeginNagmInput(String beginNagmInput) {
        this.beginNagmInput = beginNagmInput;
    }

    public void setBeginNagmMileageInput(BigDecimal beginNagmMileageInput) {
        this.beginNagmMileageInput = beginNagmMileageInput;
    }

    public void setEndNagmInput(String endNagmInput) {
        this.endNagmInput = endNagmInput;
    }

    public void setEndNagmMileageInput(BigDecimal endNagmMileageInput) {
        this.endNagmMileageInput = endNagmMileageInput;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

    public String getDataStated() {
        return dataStated;
    }

    public void setDataStated(String dataStated) {
        this.dataStated = dataStated;
    }

    public String getGisid() {
        return gisid;
    }

    public void setGisid(String gisid) {
        this.gisid = gisid;
    }

    @Override
    public void fromDomain(DifficultyRepair domain){

        // 管道编号
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 编号
        this.customNumber = domain.getCustomNumber();
        //(填写)平行起点_附近测试桩pic_pipe_identification.ID_
//        this.beginNagmInput = StringUtils.isNotNullEmpty(domain.getBeginNagmInput()) ?  PipeMgrUtil.getIdentificationNumber(domain.getBeginNagmInput()) : PipeMgrUtil.getIdentificationNumber(domain.getBeginNagm());
        this.beginNagmInput = StringUtils.isNotNullEmpty(domain.getBeginNagmNumberInput()) ?  domain.getBeginNagmNumberInput() : domain.getBeginNagmNumber();
        // (填写)平行起点_附近测试桩距离（相对值）
        Long beginNagmMileageTemp = StringUtils.isNotNullEmpty(domain.getBeginNagmNumberInput()) ? domain.getBeginNagmMileageInput() : domain.getBeginNagmMileage();
        this.beginNagmMileageInput = NumberUtil.toMeter(beginNagmMileageTemp);
        // (填写)平行段终点_附近测试桩pic_pipe_identification.ID_
//        this.endNagmInput = StringUtils.isNotNullEmpty(domain.getEndNagmInput()) ? PipeMgrUtil.getIdentificationNumber(domain.getEndNagmInput()) : PipeMgrUtil.getIdentificationNumber(domain.getEndNagm());
        this.endNagmInput = StringUtils.isNotNullEmpty(domain.getEndNagmNumberInput()) ? domain.getEndNagmNumberInput() : domain.getEndNagmNumber();
        // (填写)平行段终点_附近测试桩距离（相对值）
        Long endNagmMileageTemp = StringUtils.isNotNullEmpty(domain.getEndNagmNumberInput()) ? domain.getEndNagmMileageInput() : domain.getEndNagmMileage();
        this.endNagmMileageInput = NumberUtil.toMeter(endNagmMileageTemp);
        // 位置描述
        this.locationDescription = domain.getLocationDescription();
        // 难以接近原因AE_DIFFICULTY_REPAIR_TYPE（沼泽、湖泊、水塘、山地、河流、建构筑物、其它）
        this.reason = CodeUtil.getName(domain.getReason());

        // 数据状态
        this.dataStated = domain.getDataStated();
        this.gisid = domain.getGisid();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    public Page<DifficultyRepairVO> fromDomainList(Page<DifficultyRepair> domainList) {
        Page<DifficultyRepairVO> list = new Page<DifficultyRepairVO>();
        for (DifficultyRepair difficultyRepair : domainList) {
            DifficultyRepairVO difficultyRepairVO = new DifficultyRepairVO();
            difficultyRepairVO.fromDomain(difficultyRepair);
            list.add(difficultyRepairVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }

}